#include <bits/stdc++.h>
using namespace std;
long long a[21];
using namespace std;
int main() {
    int i,n;
    a[1]=0;
    a[2]=1;
    a[3]=2;
    for (i=4;i<=20;i++)
        a[i]=(i-1)*(a[i-1]+a[i-2]);
    while (cin>>n)
    {
        cout<<a[n]<<endl;
    }
    return 0;
//    f[i] = (i - 1) * (f[i - 1] + f[i - 2])
}
